/**
 * Copyright 2012 Vestel. All rights reserved.
 *
 * @file
 * @brief This file declares the <b>simple & light-weight</b> trace macros which are
 *         expected to be used <b>per file</b> basis.

 * Sample usage:
 * <code>
 *
 * #define FILE_TRACE
 *
 * #include "utilities_debug/file_trace.h"
 *
 * </code>
 * If the developer doesn't need any dumps from this particular file, the developer
 * needs to remark out the FILE_TRACE define and recompile the file:
 * <code>
 *
 * // #define FILE_TRACE
 *
 * #include "utilities_debug/file_trace.h"
 *
 * </code>
 *
 * Another option is defining or not FILE_TRACE at the <b>component level</b>
 * <i>via</i> the COMPONENT_DEFINES found in the <b>component.mak</b>:
 * 
 * <code>
 * COMPONENT_DEFINES += FILE_TRACE
 * </code>
 *
 * However, it is not intended to be controlled by the build scripts.
 * 
 * Note that the macros defined here are <b>very simple</b>:
 *  - There is no guarantee for the multithread usage.
 *  - Nothing can be done during run-time!
 *  - The developers usually set it <b>per file</b> which is a bit cumbersome.
 *
 * However:
 *  - No heap memory is allocated/deallocated: good for memory fragmentation
 *    and performance.
 *  - C files can use them easily without any "init" like a TRACE_PREPARE()
 *    call.
 *
 */

#ifndef FILE_TRACE_H_INCLUDED
#define FILE_TRACE_H_INCLUDED

#include <stdio.h>

/**
 * @def F_ERROR
 * @brief Print an error message always.
 */
#define F_ERROR(error)  do {printf("E R R O R: %s, %d, %s() ", __FILE__, __LINE__, __FUNCTION__); printf error;} while (0)

/**
 * @def F_PRINT
 * @brief Print a message if only FILE_TRACE is defined.
 */
#ifdef FILE_TRACE
    #define F_PRINT(trace)  do {printf("%s, %d, %s() ", __FILE__, __LINE__, __FUNCTION__); printf trace;} while (0)
#else
    #define F_PRINT(trace)
#endif

#endif // FILE_TRACE_H_INCLUDED
